import type { SuccessData } from '../types'
import type { Get } from '../client'
import type { Role } from '@/constants/role'

type ResUser = 'users'

export type UserProfile = {
  username: string
  name: string
  role: Role
}
type UserProfileSuccessData = SuccessData<UserProfile>

type LoginPayload = {
  username: string
  password: string
}
type LoginSuccessData = SuccessData<{
  accessToken: string
  refreshToken: string
}>

type UpdatePasswordPayload = {
  username: string
  oldPassword: string
  newPassword: string
}
type UpdatePasswordSuccessData = SuccessData<undefined>

type ImportStudentPayload = ({ name: string } & LoginPayload)[]
type ImportStudentSuccessData = SuccessData<UserProfile[]>

export type SearchUserQueryKey = [Get, ResUser, SearchUserPayload]
type SearchUserPayload = Partial<UserProfile>
type SearchUserSuccessData = SuccessData<UserProfile[]>

export type {
  ImportStudentPayload,
  ImportStudentSuccessData,
  LoginPayload,
  LoginSuccessData,
  UserProfileSuccessData,
  UpdatePasswordPayload,
  UpdatePasswordSuccessData,
  SearchUserPayload,
  SearchUserSuccessData
}
